<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('物料列表')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">


	<!--<div class="ui-layout-west">
		<div class="main-content">
			<div class="box box-main">
				<div class="box-header">
					<div class="box-title">
						<i class="fa icon-grid"></i> 物料分类
					</div>
					<div class="box-tools pull-right">
						<a type="button" class="btn btn-box-tool menuItem" href="#" onclick="dept()" title="管理部门"><i class="fa fa-edit"></i></a>
						<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
						<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
						<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
					</div>
				</div>
				<div class="ui-layout-content">
					<div id="tree" class="ztree"></div>
				</div>
			</div>
		</div>
	</div>-->

     <div class="container-div ui-layout-center">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								物料编码：<input type="text" name="itemCode"/>
							</li>
							<li>
								物料描述：<input type="text" name="keyWords"/>
							</li>
<!--
							<li>
								规格：<input type="text" name="spec"/>
							</li>

							<li>
								型号：<input type="text" name="model"/>
							</li>-->

							<input id="itemTypeId" name="itemTypeId" type="hidden"  />

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:itemInfo:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<!--<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:itemInfo:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:itemInfo:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:itemInfo:export">
						<i class="fa fa-download"></i> 导出
				 </a>-->
<!--				<a class="btn btn-warning" @click="synchronizedItem()">-->
<!--					<i class="fa fa-download"></i> 同步EBS物料信息-->
<!--				</a>-->
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true" style="white-space:nowrap"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
	<th:block th:include="include :: layout-latest-js" />
	<th:block th:include="include :: ztree-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:itemInfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:itemInfo:remove')}]];
        var prefix = ctx + "system/itemInfo";

        $(function() {
			var panehHidden = false;
			if ($(this).width() < 769) {
				panehHidden = true;
			}
			$('body').layout({ initClosed: panehHidden, west__size: 185 });

			queryItemInfoList();
			queryItemTypeTree();
        });

        function queryItemInfoList() {
			var options = {
				url: prefix + "/findList",
				createUrl: prefix + "/add",
				updateUrl: prefix + "/edit/{id}",
				removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
				modalName: "物料",
				showExport: true,
				columns: [{
					checkbox: true
				},
					{
						field : 'itemId',
						title : 'ID',
						visible: false
					},
					{
						field : 'itemCode',
						title : '编码',
						sortable: true
					},
					{
						field : 'itemName',
						title : '描述',
						visible: true,
						tips:true,
					},
					{
						field : 'unit',
						title : '单位',
						visible: true
					},
					{
						field : 'thickness',
						title : '厚度（毫米）',
						sortable: true
					},
					{
						field : 'maxPackQty',
						title : '单框最大存储张数',
						sortable: true,
						formatter:function(value,row,index){
							if(value === null){
								return 0;
							}else{
								return value;
							}
						}
					},
					{
						field : 'operatorNameOne',
						title : '修改人一',
						visible: true
					},
					{
						field : 'empNoOne',
						title : '修改人工号一',
						visible: true
					},
					/*{
						field : 'cardNoOne',
						title : '修改人卡号一',
						visible: true
					},*/
					{
						field : 'operatorNameTwo',
						title : '修改人二',
						visible: true
					},
					{
						field : 'empNoTwo',
						title : '修改人工号二',
						visible: true
					},
					/*{
						field : 'cardNoTwo',
						title : '修改人卡号二',
						visible: true
					},*/
					{
						title: '操作',
						align: 'center',
						width: '120px',
						formatter: function(value, row, index) {
							var actions = [];
							actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.itemId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
							actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.itemId + '\')"><i class="fa fa-remove"></i>删除</a>');
							return actions.join('');
						}
					}]
			};
			$.table.init(options);
		}

		function queryItemTypeTree()
		{
			var url = ctx + "system/itemType/treeData";
			var options = {
				url: url,
				expandLevel: 2,
				onClick : zOnClick
			};
			$.tree.init(options);

			function zOnClick(event, treeId, treeNode) {


				$("#itemTypeId").val(treeNode.id);

				$.table.search();






			}
		}

		$('#btnExpand').click(function() {
			$._tree.expandAll(true);
			$(this).hide();
			$('#btnCollapse').show();
		});

		$('#btnCollapse').click(function() {
			$._tree.expandAll(false);
			$(this).hide();
			$('#btnExpand').show();
		});

		$('#btnRefresh').click(function() {
			queryItemTypeTree();
		});

		/* 物料管理-分类 */
		function dept() {
			var url = ctx + "system/itemType";
			createMenuItem(url, "物料分类");
		}
		var app = new Vue({
			el: '.container-div',
			data: {
				message: 'Hello Vue!',
			},
			methods: {
				synchronizedItem:function(){
					$.modal.confirm("确定同步吗？",function(){
						$.operate.get("/system/itemInfo/synchronizedItem");
					});
				}
			},
			created: function () {
			},
		})
    </script>
</body>
</html>